﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace Rabbit.Converters
{
    public class DateTimeFormatConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (parameter == null)
                {
                    return Utils.DateTimeHelper.GetNormalDateStringFromString(value.ToString());
                }
                else
                {
                    return Utils.DateTimeHelper.GetDateTimeFromString(value.ToString()).ToString(parameter.ToString());
                }
            }
            catch
            {
                return "很久以前";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("we currently do not support this method!");
        }
    }
}
